	var programName = Request["programName"];
	var unitName = Request["unitName"];
	var isReview = Request["isReview"];
	var rightSound = "/student/mp3/right.mp3";
	var wrongSound = "/student/mp3/wrong.mp3";
	var isExit=false;//是否已经执行过退出事件
	
	var selectNewWord = "";//选择的生词
	var specChar = new RegExp("[.,!?]");//判断是否是标点
	jQuery(document).ready(function(){
		initCofig();//初始化格子配置
		$("body").bind("selectstart",function(){
			return false;
		});
		$("#sentenceEn,#sentence").on("click","span.word",function(event){//划词
			selectNewWord = "";
			var selectObj = $(this);
			if(selectObj.find("div").length>0){
				if(selectObj.find(".tips-word").is(":visible")){
					selectObj.removeClass("tips");
					selectObj.find("div").hide();
				}else{
					$("#sentenceEn,#sentence").find("span.word").removeClass("tips");
					$("#sentenceEn,#sentence").find("div").hide();
					selectObj.find("div").show();
					selectObj.addClass("tips");
				}
			}else{
				$("#sentenceEn,#sentence").find("div").hide();
				$("#sentenceEn,#sentence").find("span.word").removeClass("tips");
				var _spelling = $(this).html();
				if((wordLoader.step==1||wordLoader.step==2)&&_spelling.length>0){
					selectObj.addClass("tips");
					var _html = "";
					_html+="<div class=\"tips-word\"></div>";
					_html+="<div class=\"tips-box\">";
					_html+="<div class=\"tips-title\">"+_spelling+"</div>";//data.word.syllable
					_html+="<div class=\"tips-content\">正在查到词义...</div>";
					_html+="</div>";
					selectObj.append(_html);
					$.ajax({
						url:'/student/newWord/queryMeaning',
						data:{"spelling":_spelling},
						cache:false,
						dataType:"json",
						type:"post",
						success: function(data){
							if(selectObj.find("div").length>0){
								selectObj.find("div").remove();
								var _html = "";
								_html+="<div class=\"tips-word\"></div>";
								_html+="<div class=\"tips-box\">";
								_html+="<div class=\"tips-title\">"+_spelling+"</div>";//data.word.syllable
								if(data.word==null){
									_html+="<div class=\"tips-content\"></div>";
									_html+="<div class=\"tips-content\">未查到词义</div>";
								}else{
									selectNewWord = _spelling;
									_html+="<div class=\"tips-content\">"+data.word.meaning+"</div>";
									_html+="<div class=\"tips-content\">"+(data.word.example!=undefined&&data.word.example!=null?("[例句]"+data.word.example):"")+"</div>";
									_html+="<div class=\"tips-content\">"+(data.word.example!=undefined&&data.word.example!=null?(""+data.word.example_zh_CN):"")+"</div>";
									_html+="<button type=\"button\" class=\"btn btn-super-small-yellow\" onclick=\"addNewWord();\">加入生词本</button>";
								}
								_html+="</div>";
								selectObj.append(_html);
							}
						}
					});
				}
			}
		});
	}).bind("dblclick",function(){
		return false;
	}).keydown(function(e){
		switch(e.keyCode){
			case 16://shift
				if(wordLoader.step==3){
					$("#sentenceEn").css("visibility","");
				}
				break;
		}
	});
	//倒计时！！！
	var respTime = {
		spentTime:0,
		timeOut:false,
		timeId:0,
		timeCount:function(callback){
			this.spentTime--;
			jQuery("#countTime").html(this.spentTime);
			if(this.spentTime==0){
				this.timeOut = true;
				jQuery("#countTime").html("已超时");
				if(callback!=undefined){
					callback();
				}
				return;
			}
			this.timeId = setTimeout("respTime.timeCount("+callback+")",1000);
		},
		init:function(){
			clearTimeout(this.timeId);
			this.timeOut = false;
			this.timeId = 0;
			if(deviceType==13){
				this.spentTime = Math.ceil(wordLoader.word.words.length*2);//例句听力    1.5:先前的值
			}else{
				this.spentTime = Math.ceil(wordLoader.word.words.length*3);//例句翻译    2.5:先前的值
			}
			jQuery("#countTime").html(this.spentTime);
		},
		action:function(callback){//开始倒计时
			this.timeId = setTimeout("respTime.timeCount("+callback+")",1000);
		}
	};
	
	/**
	 * 加入生词本
	 */
	function addNewWord(){
		$("#sentenceEn span.word div").remove();
		var _spelling = selectNewWord;
		//加入生词本
		$.ajax({
			url:'/student/newWord/addNewWord',
		   	data:{"spelling":_spelling},
		   	cache:false,
		   	dataType:"json",
			type:"post",
			success: function(data){
				if(data.success){
					alert("添加生词本成功！");
				}else{
					if(data.errorId==1){
						alert("生词本中已经添加过'"+_spelling+"'了！");
					}else{
						alert("添加生词本失败！");
					}
				}
			}
		});
	}
	function showHelp(){
		/*if(wordLoader.tipStatus==0){
			$("#helpDiv input:checkbox").prop("checked",false);
		}else{
			$("#helpDiv input:checkbox").prop("checked",true);
		}*/
		easyDialog.open({
			isOverlay : true,
			container : 'helpDiv'
		});
	}
	/**
	 * 学习小结
	 */
	function studySummary(){
		var cal = Math.floor( wordLoader.effectTime / 60);
		var _html="";
		if(wordLoader.todayCredits>=500){
			_html = "<div id='moment'>今日获得学分已达上限<span class=\"red\">500</span>分，学习以及测试将不会有金币奖励！</div>";
		}else{
			_html = "<div id='moment'>本次学习获得金币：<span class=\"red\">"+cal+"</span>个</div>";
		}
		var dialogR = dialog({
			id: 'studytipbox',
			title: "学习小结",
			width: '400px',
			content:_html,
			okValue: "退出",
			ok: function () {
				wordLoader.exit();
				return false;
			},
			cancelValue: "继续学习",
			//取消创建PK试卷事件
			cancel: function () {}
		});
		dialogR.showModal();
	}
	function closeHelp(){
		/*if(wordLoader.needLoadData){
			wordLoader.getNext();
		}
		var _nowTipStatus = 0;
		if($("#helpDiv input:checkbox").is(":checked")){_nowTipStatus=1;}else{_nowTipStatus=0;}
		if(_nowTipStatus!=wordLoader.tipStatus){
			$.ajax({
				url:'/student/studyFlow/saveTipStatus',
			   	data:{"tipStatus":_nowTipStatus,"deviceType":deviceType},
			   	cache:false,
			   	dataType:"json",
				type:"post",
				success: function(data){
					if(data.success){
						wordLoader.tipStatus = _nowTipStatus;
					}
				}
			});
		}*/
		easyDialog.close();
	}
	
	/**
	 * 保存学习时间
	 */
	function saveStudyTime(){
		$.ajax({
			url:'/student/studyFlow/saveStudyTime',
		   	cache:false,
			type:"post"
		});
	}
	
	function toStudyCenter(){
		window.location.href="/student/learning-center-sentence.html?programName="+programName+"&deviceType="+deviceType;
	}
	
	window.onbeforeunload=wordLoader.exit;
	function stop(){
		return false;
	}
	document.oncontextmenu=stop;